package com.nep.test;

import com.nep.entity.GridMember;
import java.io.*;
import java.util.ArrayList;
import java.util.List;

public class InitGridMember {
    private static final String GRID_MEMBER_FILE = "gridmember.data";
    
    public static void main(String[] args) {
        System.out.println("=== 开始初始化网格员数据 ===");
        
        List<GridMember> gridMembers = new ArrayList<>();
        
        // 创建网格员账号
        GridMember gm1 = new GridMember();
        gm1.setLoginCode("1");
        gm1.setPassword("1");
        gm1.setRealName("张三");
        gm1.setGmTel("13800138001");
        gm1.setState("工作中");
        gridMembers.add(gm1);
        
        GridMember gm2 = new GridMember();
        gm2.setLoginCode("2");
        gm2.setPassword("2");
        gm2.setRealName("李四");
        gm2.setGmTel("13800138002");
        gm2.setState("工作中");
        gridMembers.add(gm2);
        
        GridMember gm3 = new GridMember();
        gm3.setLoginCode("3");
        gm3.setPassword("3");
        gm3.setRealName("王五");
        gm3.setGmTel("13800138003");
        gm3.setState("工作中");
        gridMembers.add(gm3);
        
        // 保存到文件
        try (ObjectOutputStream oos = new ObjectOutputStream(
                new FileOutputStream(GRID_MEMBER_FILE))) {
            oos.writeObject(gridMembers);
            System.out.println("网格员数据已成功保存到 " + GRID_MEMBER_FILE);
        } catch (IOException e) {
            System.err.println("保存网格员数据时出错: " + e.getMessage());
            e.printStackTrace();
        }
        
        System.out.println("网格员数据初始化完成！");
        System.out.println("共初始化了 " + gridMembers.size() + " 个网格员账号：");
        for (GridMember gm : gridMembers) {
            System.out.println("账号: " + gm.getLoginCode() + 
                             ", 姓名: " + gm.getRealName() + 
                             ", 状态: " + gm.getState());
        }
    }
} 